﻿namespace System.Xml.Serialization.Internal
{
    using System.Reflection;

    internal class XmlRuntimeProperty<T> : IXmlRuntimeProperty<T>
    {
        private object _obj;
        private PropertyInfo _property;

        public XmlRuntimeProperty(object value, PropertyInfo property)
        {
            _obj = value;
            _property = property;
        }

        #region IRuntimeProperty<T> Members

        public T Value
        {
            get
            {
                return (T)_property.GetValue(_obj, null);
            }
            set
            {
                _property.SetValue(_obj, value, null);
            }
        }

        #endregion

        #region IRuntimeProperty Members

        public string PropertyName
        {
            get { return _property.Name; }
        }

        #endregion
    }
}
